home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 1 / CU Amiga Magazine CD-ROM Special Edition (1995)(EMAP Images)(GB)[Issue 1995-11].iso / Aminet / disk / cdrom / CDSpeed10.lha / CDSpeed.c < prev    next >
C/C++ Source or Header  |  1995-05-15  |  2KB  |  76 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3.  
  4. #include <exec/io.h>
  5. #include <utility/tagitem.h>
  6.  
  7. #include <clib/exec_protos.h>
  8. #include <clib/alib_protos.h>
  9. #include <clib/dos_protos.h>
  10.  
  11. #include <stdio.h>
  12.  
  13. #include <devices/cd.h>
  14.  
  15. struct MsgPort *cdport;
  16. struct IOStdReq *cdreq;
  17.  
  18. struct TagItem newconfig[] = {
  19.     TAGCD_READSPEED, 150,
  20.     TAG_DONE
  21.     };
  22.  
  23. UBYTE *Version = "$VER: CDSpeed 1.0 (14.05.95)";
  24.  
  25. void clean_up(char *text);
  26.  
  27. void main()
  28. {
  29.     struct CDInfo Info;
  30.  
  31.     if(!(cdport = CreateMsgPort()))
  32.         clean_up("Could not create port");
  33.     if(!(cdreq = CreateIORequest(cdport, sizeof(struct IOStdReq))))
  34.         clean_up("Could not create IORequest");
  35.  
  36.     if(OpenDevice("cd.device", 0, (struct IORequest *)cdreq, 0))
  37.         clean_up("Could not open cd.device");
  38.  
  39.     cdreq->io_Command = CD_INFO;
  40.     cdreq->io_Data = &Info;
  41.     cdreq->io_Length = sizeof(struct CDInfo);
  42.  
  43.     DoIO((struct IORequest *)cdreq);
  44.  
  45.     if(!cdreq->io_Error) {
  46.         Printf("The CD's speed is %ld bytes/sec.\n", Info.ReadSpeed*2048);
  47.         Printf("Your drive is capable of %ld bytes/sec.\n", Info.MaxSpeed*2048);
  48.         newconfig[0].ti_Data = Info.MaxSpeed;
  49.         cdreq->io_Command = CD_CONFIG;
  50.         cdreq->io_Data = &newconfig;
  51.         cdreq->io_Length = 0;
  52.         DoIO((struct IORequest*)cdreq);
  53.         if(!cdreq->io_Error)
  54.             Printf("The speed is now maximized!\n");
  55.         else
  56.             Printf("Unable to change speed\n");
  57.         }
  58.  
  59.     clean_up(0);
  60.  
  61. }
  62.  
  63. void clean_up(char *text)
  64. {
  65.     Printf("%s\n", text);
  66.  
  67.     if(cdreq) CloseDevice((struct IORequest *)cdreq);
  68.  
  69.     if(cdreq) DeleteIORequest(cdreq);
  70.     if(cdport) DeleteMsgPort(cdport);
  71.     exit(0);
  72. }
  73.  
  74.  
  75.  
  76.